package ysq.xyg.web.model.po;

import cn.hutool.core.util.StrUtil;
import lombok.NoArgsConstructor;

import lombok.Data;
import ysq.xyg.base.util.BaseConstant;
import ysq.xyg.base.util.BaseUtil;
import ysq.xyg.sys.model.po.SysUser;

import javax.persistence.Column;
import javax.persistence.Id;
import javax.persistence.Table;
import java.io.Serializable;
import java.util.Date;

/**
 * 网站模块-标签内容关联表实体类
 *
 * @author shengQiang yu
 * @date 2019-6-7 20:44:32
 */
@Data
@NoArgsConstructor
@Table(name = "xyg_web_tag_content")
public class WebTagContent implements Serializable{

	/**
     * 主键
     */ 
	@Id
	private String id;
	
	/**
     * 标签主键
     */ 
	@Column(name = "tag_id")
	private String tagId;
	
	/**
     * 标签类型:1、文章标签，2、商品标签，3、栏目标签
     */ 
	@Column(name = "tag_type")
	private String tagType;
	
	/**
     * 关联id
     */ 
	@Column(name = "extend_id")
	private String extendId;
	
	/**
     * 用户id
     */ 
	@Column(name = "user_id")
	private String userId;
	
	/**
     * 删除标识：1、正常，2、已删除
     */ 
	@Column(name = "remove_tag")
	private String removeTag;
	
	/**
     * 创建人
     */ 
	@Column(name = "create_user")
	private String createUser;
	
	/**
     * 创建时间
     */ 
	@Column(name = "create_time")
	private Date createTime;
	
	/**
     * 修改人
     */ 
	@Column(name = "update_user")
	private String updateUser;
	
	/**
     * 修改时间
     */ 
	@Column(name = "update_time")
	private Date updateTime;
	

	public WebTagContent(SysUser sysUser) {
		this.id= BaseUtil.uId();
		this.removeTag= BaseConstant.BASE_REMOVE_TAG_NORMAL;
		this.createTime = new Date();
		this.createUser = sysUser.getId();
		this.updateTime = new Date();
		this.updateUser = sysUser.getId();
	}

	public WebTagContent(String tagId, String tagType, String extendId,SysUser sysUser) {
		this.tagId = tagId;
		this.tagType = tagType;
		this.extendId = extendId;
		this.userId=sysUser.getId();
		this.id= BaseUtil.uId();
		this.removeTag= BaseConstant.BASE_REMOVE_TAG_NORMAL;
		this.createTime = new Date();
		this.createUser = sysUser.getId();
		this.updateTime = new Date();
		this.updateUser = sysUser.getId();
	}

	public WebTagContent(String tagId, String extendId) {
		if(StrUtil.isNotEmpty(tagId)){
			this.tagId = tagId;
		}
		if(StrUtil.isNotEmpty(extendId)){
			this.extendId = extendId;
		}
	}
}